package intializer;

import handler.ComByteToMessageDecoder;
import handler.ComClientInboundChannelHandler;
import handler.ComMessageToByteEncoder;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import lombok.Data;

@Data
public class ComClientChannelInitializer extends ChannelInitializer<SocketChannel> {

    private ComClientInboundChannelHandler inboundChannelHandler = new ComClientInboundChannelHandler();

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();
        pipeline.addLast(new ComMessageToByteEncoder())
                .addLast(new ComByteToMessageDecoder())
                .addLast(inboundChannelHandler);

    }
}
